Split the dec2flt::RawFloat trait for easier reuse#151905
Open
tgross35 wants to merge 5 commits intorust-lang:mainfrom
Open
Split the dec2flt::RawFloat trait for easier reuse#151905tgross35 wants to merge 5 commits intorust-lang:mainfrom
dec2flt::RawFloat trait for easier reuse#151905tgross35 wants to merge 5 commits intorust-lang:mainfrom
Conversation
Collaborator
|
|
Collaborator
Contributor
Author
|
The first two commits can be ignored since they are part of #151900 |
9837f1e to
ec32d31
Compare
This comment has been minimized.
This comment has been minimized.
ec32d31 to
89457ed
Compare
This comment has been minimized.
This comment has been minimized.
89457ed to
038d60f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Currently we have a single `core::num` module that contains both thin wrapper API and higher-complexity numeric routines. Restructure this by moving implementation details to a new `imp` module. This results in a more clean separation of what is actually user-facing compared to items that have a stability attribute because they are public for testing.
038d60f to
6404669
Compare
Collaborator
|
This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
ff1a43f to
be9bca8
Compare
This comment has been minimized.
This comment has been minimized.
be9bca8 to
4415a63
Compare
Follow up to the previous commit refactoring `core::num` by moving the user-facing error types and trait implementations back out of `imp` and into a new module under `core::num`.
This is more consistent with what the trait is called elsewhere in tree (specifically compiler-builtins and test-float-parse).
`RawFloat` is currently used specifically for the implementation of the lemire algorithm, but it is useful for more than that. Split it into three different traits: * `Float`: Anything that is reasonably applicable to all floating point types. * `FloatExt`: Items that should be part of `Float` but don't work for all float types. This will eventually be merged back into `Float`. * `Lemire`: Items that are specific to the Lemire algorithm.
4415a63 to
9c9c758
Compare
This comment has been minimized.
This comment has been minimized.
9c9c758 to
9b11126
Compare
This comment has been minimized.
This comment has been minimized.
`Float` and `FloatExt` are already used by both parsing and printing, so move them out of `dec2flt` to a new module in `num::imp`. `Int` `Cast` have the potential to be used more places in the future, so move them there as well. `Lemire` is the only remaining trait; since it is small, move it into the `dec2flt` root. The `fmt::LowerExp` bound is removed from `Float` here since the trait is moving into a module without `#[cfg(not(no_fp_fmt_parse))]` and it isn't implemented with that config (it's not easily possible to add `cfg` attributes to a single supertrait, unfortunately). This isn't a problem since it isn't actually being used.
9b11126 to
64b5ed9
Compare
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
RawFloatis an internal trait with quite a few useful float properties. It currently resides in thedec2fltmodule but is also used in parsing, and would be nice to reuse other places. Unfortunately it cannot be implemented onf128because of limitations with how the parsing API is implemented (mantissa must fit into a u64).To make the trait easier to work with, split it into the following:
Float: Anything that is reasonably applicable to all floating point types.FloatExt: Items that should be part ofFloatbut don't work for all float types. This will eventually be merged back intoFloatonce it can be implemented on f128.Lemire: Items that are specific to the Lemire dec2flt algorithm.These traits are then moved to places that make sense.
Builds on top of #151900